#include "Utils.hpp"

#include <sstream>

////////////////////////////////////////////////////////////////
// position_t
//
std::ostream& operator<<(std::ostream& os, const position_t& p)
{
	return os << '('
		<< p.x << ','
		<< p.y << ','
		<< p.z << ')';
}

////////////////////////////////////////////////////////////////
// TermColor
//
namespace TermColor
{
	namespace
	{
		const char* cf[Size] = 
		{
			"\x1b[31m", "\x1b[32m", "\x1b[34m",
			"\x1b[33m", "\x1b[35m", "\x1b[36m",
			"\x1b[30m", "\x1b[37m", "\x1b[39m"
		};

		bool disable = 1;

#ifdef unix
		// in linux environment, enable by default.
		void init() __attribute__((constructor));
		void init()
		{
			disable = 0;
		}
		void term() __attribute__((destructor));
		void term()
		{
			std::cout << TermColor::Default << TermColor::Back::Default << std::endl;
		}
#endif

	}

	std::ostream& operator<<(std::ostream& os, Fore f)
	{
		// assert(f != Size);
		return os << cf[f];
	}

	namespace Back
	{
		namespace
		{
			const char* cb[Back::Size] = 
			{
				"\x1b[41m", "\x1b[42m", "\x1b[44m",
				"\x1b[43m", "\x1b[45m", "\x1b[46m",
				"\x1b[40m", "\x1b[47m", "\x1b[49m",
			};
		}

		std::ostream& operator<<(std::ostream& os, Back b)
		{
			// assert(f != Size);
			return os << cb[b];
		}
	}

	/**
	* @brief Disable coloring.
	*/
	void DisableColoring()
	{
		disable = 1;
	}
}

/**
* @class CProperty
* 
* @brief Interface for structure of object-tree with CPlayers.
*/

/**
* @class ptr_vector
*
* Vector of pointers with ownership.
* When this destructed, Elements will be deleted.
*
* @warning Do not cast and delete as std::vector because this class dont use protected-derivation.
*/

